![]() |
PATH![]() |
![]() ![]() |
Application commands are commands that cause actions in scriptable applications. The target of an application command is an application object or a script object. Different application objects respond to different commands. You can determine which commands an application supports by examining the application's dictionary. You can view an application's dictionary by dropping the application's icon on the Script Editor's icon, or by opening the application with the Script Editor's Open Dictionary command. Table 5-1 and Table 5-2 show excerpts from the dictionaries for the Finder and for AppleWorks, respectively. For related information, see Dictionaries.
There are two ways to specify an object as the target of a command: in the direct parameter of the command or in a Tell statement that contains the command.
The direct parameter is a value, usually a reference, that appears immediately after a command and specifies the target of the command. Not all commands have a direct parameter. If a command can have a direct parameter, the command's definition says so.
For example, in the following statement, the reference last file of window 1 of application "Finder" is the direct parameter of the Duplicate command:
duplicate last file of window 1 of application "Finder"
A Tell statement is a statement that specifies a default target for all commands contained within it. If a command is contained within a Tell statement, the direct parameter is optional. If you leave out the direct parameter, AppleScript uses the default target specified in the Tell statement. For example, the Duplicate command in the following Tell statement has the same effect as the Duplicate command in the previous example:
tell last file of window 1 of application "Finder"
duplicate
end tell
Similarly, if you specify a reference incompletely in the command line, AppleScript uses the default target specified in the enclosing Tell statement to complete the reference. For example, the following statement is equivalent to both of the previous examples:
tell window 1 of application "Finder"
duplicate last file
end tell
Remember that you can make your script statements look more like written English if you choose. For example, the following statement is the same, syntactically, as the first Duplicate statement above:
duplicate the last file of the first window of application "Finder"
For a definition of script objects, as well as information on sending application commands to script objects, see Script Objects.